package com.visionvera.myapplication.net;//package com.visionvera.retrofitservice;

import com.visionvera.retrofitservice.net.BaseEntity;
import com.visionvera.retrofitservice.net.URLConfig;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * Created by dongyukun on 2017/11/7.
 */

public interface APIFunction {
    @POST("appuser/verify.action")
    Observable<BaseEntity<LoginBean>> doLogin(@QueryMap Map<String, String> map);

    @GET(URLConfig.baidu_url)
    Observable<BaseEntity> getBaidu(@Query("wd") String name);

    @POST(URLConfig.login_token_url)
    Call<String> loginByToken(@Query("mobile") String mobile, @Query("token") String cookie);

    //上传单张图片
    @Multipart
    @POST("appuser/updateUserImage.action")
    Observable<BaseEntity> imageUpload(@Part List<MultipartBody.Part> partList);

    @Multipart
    @POST("appuser/updateUserImage.action")
    Observable<BaseEntity> doUpdatePhoto(@Part("file") MultipartBody body, @PartMap Map<String, RequestBody> map);

    //上传多张图片
    @POST("服务器地址")
    Observable<Object> imagesUpload(@Part() List<MultipartBody.Part> imgs);


    /**
     * @param page
     * @param number
     * @return
     */
    @Headers("Cache-Control: public, max-age=100")//设置缓存 缓存时间为100s
    @GET("everySay/selectAll.do")
    Observable<BaseEntity> lookBack(@Query("page") int page, @Query("rows") int number);


    @POST("upload/uploadFile.do")
    Observable<BaseEntity> uploadFiles(@Part("filename") String description,
                                       @Part("pic\"; filename=\"image1.png") RequestBody imgs1,
                                       @Part("pic\"; filename=\"image2.png") RequestBody imgs2);

    @POST("upload/uploadFile.do")
    Observable<BaseEntity> uploadFiles(@Part("filename") String description, @PartMap() Map<String, RequestBody> maps);
}
